package com.imooc.miaosha.service;

import com.imooc.miaosha.dao.UserDao;
import com.imooc.miaosha.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {
	@Autowired
	UserDao userDao;

	public User getUser(int id){
		return userDao.selectById(id);
	}

	@Transactional(rollbackFor = Exception.class)
	public int insert(String name){
		User user = new User();
		user.setName(name);

		User user1 = new User();
		user1.setName("哈哈哈哈");
		userDao.insert(user1);

		int i = 1/0;

		return userDao.insert(user);
	}
}
